package cn.com.api.mapper.base;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.api.entity.ApiT_products;

//DAO
public interface T_productsMapperBase {

	// 根据id查看
	@Select("SELECT * FROM t_products  WHERE product_id = #{product_id}")
	public ApiT_products findT_productsById(Long product_id);

	// 查看数据集
	@Select("SELECT * FROM T_products")
	public List<ApiT_products> findT_productss();

	// 添加
	@Insert("INSERT INTO t_products (goods_id, sku_code, erp_barcode, erp_product_id, erp_goods_sn, mkt_price, price, spec, pdt_spec, store, unit, is_delete, city_id, shop_id, create_time, update_time, description, status, sold, is_top) VALUES (#{goods_id}, #{sku_code}, #{erp_barcode}, #{erp_product_id}, #{erp_goods_sn}, #{mkt_price}, #{price}, #{spec}, #{pdt_spec}, #{store}, #{unit}, #{is_delete}, #{city_id}, #{shop_id}, #{create_time}, #{update_time}, #{description}, #{status}, #{sold}, #{is_top})")
	@Options(useGeneratedKeys = true, keyProperty = "product_id")
	public int insertT_products(ApiT_products t_products);

	// 修改
	@Update("UPDATE t_products SET goods_id = #{goods_id}, sku_code = #{sku_code}, erp_barcode = #{erp_barcode}, erp_product_id = #{erp_product_id}, erp_goods_sn = #{erp_goods_sn}, mkt_price = #{mkt_price}, price = #{price}, spec = #{spec}, pdt_spec = #{pdt_spec}, store = #{store}, unit = #{unit}, is_delete = #{is_delete}, city_id = #{city_id}, shop_id = #{shop_id}, create_time = #{create_time}, update_time = #{update_time}, description = #{description}, status = #{status}, sold = #{sold}, is_top = #{is_top} WHERE product_id = #{product_id}")
	public int updateT_products(ApiT_products t_products);

	// 删除
	@Delete("DELETE FROM t_products  WHERE product_id = #{product_id}")
	public int deleteT_products(Integer product_id);

	// Foreign keys revelant

	// 删除根据Goods_id
	@Delete("DELETE FROM t_products  WHERE goods_id = #{goods_id}")
	public int T_productsDeleteByGoods_id(String goods_id);

	// 获取根据Goods_id
	@Select("SELECT product_id, goods_id, sku_code, erp_barcode, erp_product_id, erp_goods_sn, mkt_price, price, spec, pdt_spec, store, unit, is_delete, city_id, shop_id, create_time, update_time, description, status, sold, is_top FROM t_products  WHERE goods_id = #{goods_id}")
	public List<ApiT_products> findT_productssByGoods_id(String goods_id);

	// region Indexs revelant

}
